package com.tosit.bmx.service.admin.Impl;

import com.tosit.bmx.domian.News;
import com.tosit.bmx.domian.Online;
import com.tosit.bmx.domian.Usershow;
import com.tosit.bmx.mapper.NewsMapper;
import com.tosit.bmx.mapper.OnlineMapper;
import com.tosit.bmx.mapper.UsershowMapper;
import com.tosit.bmx.service.admin.WebManagerService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author tsl
 * @create 2018-04-26 17:14
 **/
@Service
public class WebManagerServiceImpl implements WebManagerService {

    @Autowired
    UsershowMapper usershowMapper;
    @Autowired
    NewsMapper newsMapper;
    @Autowired
    OnlineMapper onlineMapper;


    /**
     * 获取所有会员展示
     *
     * @param
     * @return
     * @author tsl
     * @date 2018/4/26 17:24
     */
    @Override
    public List<Usershow> gainUserShowAll() {
        return usershowMapper.selectAll();
    }
    /**
     * 添加会员展示
     *
     * @param
     * @return
     * @author tsl
     * @date 2018/4/26 17:24
     */
    @Override
    @Transactional
    public Integer addUserShow(Usershow usershow) {
        return usershowMapper.insertSelective(usershow);
    }
    /**
     * 删除会员展示
     *
     * @param ids
     * @return
     * @author tsl
     * @date 2018/4/26 17:24
     */
    @Override
    @Transactional
    public Integer removeUserShows(List<Integer> ids) {
        return usershowMapper.deleteUsers(ids);
    }
    /**
     * 更新会员展示信息
     *
     * @param
     * @return
     * @author tsl
     * @date 2018/4/26 17:24
     */
    @Override
    @Transactional
    public Integer modifyUserShow(Usershow usershow) {
        return usershowMapper.updateByPrimaryKeySelective(usershow);
    }
    /**
     * 获取所有新闻
     *
     * @param
     * @return
     * @author tsl
     * @date 2018/4/26 17:24
     */
    @Override
    public List<News> gainNewsAll() {
        return newsMapper.selectNewsAll();
    }

    @Override
    @Transactional
    public Integer addNew(News news) {
        return newsMapper.insertSelective(news);
    }

    @Override
    @Transactional
    public Integer removeNews(List<Integer> ids) {
        return newsMapper.deletes(ids);
    }

    @Override
    @Transactional
    public Integer modifyNews(News news) {
        return newsMapper.updateByPrimaryKeySelective(news);
    }

    @Override
    public List<News> seekNews(String keyCode) {
        return newsMapper.seekNews(keyCode);
    }

    @Override
    public List<Online> gainOnlineAll() {
        return onlineMapper.selects();
    }

    @Override
    @Transactional
    public Integer addOnline(Online online) {
        return onlineMapper.insertSelective(online);
    }

    @Override
    @Transactional
    public Integer removeOnline(List<Integer> ids) {
        return onlineMapper.deletes(ids);
    }

    @Override
    @Transactional
    public Integer modifyOnline(Online online) {
        return onlineMapper.updateByPrimaryKeySelective(online);
    }
}
